#ifndef _SQUIRREL_WRAPPER_H_
#define _SQUIRREL_WRAPPER_H_

#include "sqplus.h"

class Scriptable
{
public:
	SquirrelObject& getObject() const
	{
		return m_obj;
	}
	void setObject(SquirrelObject obj)
	{
		m_obj = obj;
	}

protected:
	bool overrided(const SQChar* name,SquirrelObject& func) const
	{
		if(!func.IsNull())
			return true;
		func=m_obj.GetValue(name);
		return !func.IsNull();
	}

	template<typename R>
	SqPlus::SquirrelFunction<R> getFunction(SquirrelObject& func)
	{
		SquirrelFunction<R> f(m_obj,func);
		return f;
	}

	mutable SquirrelObject m_obj;
};

#endif
//make a squirrel imp for exporting
/*class SQFOO : public FOO, public wrapper<FOO>
{
public:
         virtual void do(void)
        {
                  getFunction<void>("do")();
        }
};

int FooConstructor(HSQUIRRELVM v)
{
         SQFOO* f = new SQFOO();
        int r =  PostConstruct<SQFOO>(v, state, ReleaseClassPtr<SQFOO>::release);
        StackHandler sa(v);
        HSQOBJECT ho = sa.GetObjectHandle(1); // OT_INSTANCE
        SquirrelObject instance(ho);
        state->setObject(instance);
        return r;
}
*/